package com.richard.demo.controller.handler;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import java.io.IOException;
import java.io.PrintWriter;

//用户异常统一处理器
@ControllerAdvice
public class UserExceptionHandler {
    @ExceptionHandler(MaxUploadSizeExceededException.class)
        public void uoloadException(MaxUploadSizeExceededException e, HttpServletResponse response)
            throws IOException {
                System.out.println(e.getMessage());
                response.setContentType("text/html;charset=utf-8");
                PrintWriter writer = response.getWriter();
                writer.write("服务器吃不下啦qaq");
                writer.flush();
                writer.close();
    }
}
